package mi905;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @author tmh
 * @date 2024/9/17 20:19
 * @description
 */
public class TBread {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int count = scanner.nextInt();
        int[] arrayA = new int[count];
        int[] arrayB = new int[count];
        for (int i = 0; i < count; i++) {
            arrayA[i] = scanner.nextInt();
        }
        for (int i = 0; i < count; i++) {
            arrayB[i] = scanner.nextInt();
        }
        //先得到两个数组中的最小值，然后去看获得他们是不是都是同一台机器
        int indexA = 0;
        int indexB = 0;
        for (int i = 0; i < count; i++) {
            if (arrayA[i] < arrayA[indexA]) {
                indexA = i;
            }
            if (arrayB[i] < arrayB[indexB]) {
                indexB = i;
            }
        }
        int result1 = 0;

        //看看indexA和indexB是否是相等，不相同则说明可以用不同的机器
        if (indexA != indexB) {
            result1 = Math.max(arrayA[indexA], arrayB[indexB]);
        } else {
            result1 = arrayA[indexA] + arrayB[indexB];
        }
        System.out.println(result1);
    }
}
